{extend name="public/base"/}
{block name="content"}
<!-- Content Header (Page header) -->
<section class="content-header">
	<h1>
		内容管理
		<small>Optional description</small>
	</h1>
	<ol class="breadcrumb">
		<li><a href="{:U('Index/index')}"><i class="fa fa-dashboard"></i> 首页</a></li>
		<li class="active">内容管理</li>
	</ol>
</section>
<!-- Main content -->
<section class="content" style="min-height:980px;">
	<div class="col-md-9" style="padding:0; width:100%">
		<div class="box box-primary">
			<div class="box-header with-border">
				<h3 class="box-title" style="float:left;overflow: hidden;zoom:1;padding-top: 8px;"><a href="#">内容发布</a></h3>

				<!-- 搜索 -->
				<form action="{:U('Content/listsearch')}" method="post">
					<div class="box-tools pull-right">
						<div class="has-feedback" style="zoom:1;overflow: hidden;">

							<input type="text" class="form-control input-sm" name="name" value="" placeholder="输入标题名称" style="float:left;">

							<input  style="border:0;float: left; font-size: 12px; height: 30px; position: absolute; right: 0; top: 0;" type="submit" value="搜索" />

						</div>
					</div>
				</form>
				<!-- 搜索 END-->




			</div>

			<div class="box-body no-padding">

				<div class="table-responsive mailbox-messages">
					<table class="table table-hover table-striped" id="list">
						<tbody>
						<!-- 标题栏 -->
						<tr>
							<td></td>
							<td style="width:60px;"><a href="">排序</a></td>
							<td class="mailbox-star"><a href="#">标题</a></td>
							<td class="mailbox-star"><a href="#">显示</a></td>
							<td class="mailbox-star"><a href="#">推荐</a></td>
							<td class="mailbox-star"><a href="#">置顶</a></td>
							<td class="mailbox-star"><a href="#">更新时间</a></td>
							<td class="mailbox-star"><a href="#">发表时间</a></td>
							<td class="mailbox-star"><a href="#">管理操作</a></td>
						</tr>
						<!-- 标题栏 END -->


						<!-- 循环列表 默认循环20条 高度为980px -->
						{volist name="search" id="data"}
						<tr>
							<td><input name="select_id" type="checkbox" value="{$data.id}"></td>
							<td><input name="listorder" class="listorder"  type="text" data-orderid="{$data.id}"  value="{$data.listorder}" /></td>
							<td class="mailbox-subject" width="40%">{$data.name}</td>
							<td class="mailbox-star">{if condition="($data.status eq 1)"}是{else /}否{/if}</td>
							<td class="mailbox-star">{if condition="($data.rec_ok eq 1)"}推荐{else /}不推荐{/if}</td>
							<td class="mailbox-star">{if condition="($data.top_ok eq 1)"}置顶{else /}不置顶{/if}</td>
							<td class="mailbox-attachment">2016-03-15</td>
							<td class="mailbox-date">2016-02-14</td>
							<td class="mailbox-date">
								<a href="{:U('Content/delContent',array('term_id'=>$data['term_id'],'id'=>$data['id'],'model_id'=>$data['model_id']))}">删除</a>&nbsp;|&nbsp;
								<a href="{:U('Content/editContent',array('term_id'=>$data['term_id'],'id'=>$data['id'],'model_id'=>$data['model_id']))}">编辑</a>&nbsp;|&nbsp;
								<a href="/">访问[暂无]</a>
							</td>
						</tr>
						{/volist}
						<!-- 循环列表 END -->


						</tbody>
					</table>
				</div>
			</div>



			<div class="box-footer no-padding" >
				<div class="mailbox-controls" style="margin-top:20px;margin-bottom:10px;">
					<input type="checkbox" id="all">
					<input type="button" value="全选" class="btn" id="selectAll">
					<input type="button" value="全不选" class="btn" id="unSelect">
					<input type="button" value="反选" class="btn" id="reverse">
					<input type="button" value="删除" class="btn" onclick="fn();">
					{$page}
				</div>

			</div>
		</div>


		<!-- /. box -->
	</div>

	<!-- 批量删除 -->
	<script>
		$(function () {

			$("#all").click(function(){
				if(this.checked){
					$("#list :checkbox").prop("checked", true);
				}else{
					$("#list :checkbox").prop("checked", false);
				}
			});

			$("#selectAll").click(function () {
				$("#list :checkbox,#all").prop("checked", true);
			});

			$("#unSelect").click(function () {
				$("#list :checkbox,#all").prop("checked", false);
			});

			$("#reverse").click(function () {
				$("#list :checkbox").each(function () {
					$(this).prop("checked", !$(this).prop("checked"));
				});
				allchk();
			});


			$("#list :checkbox").click(function(){
				allchk();
			});


		});


		function getValue(){
			var id = document.getElementsByName('select_id');
			var value = new Array();
			for(var i = 0; i < id.length; i++){
				if(id[i].checked)
					value.push(id[i].value);
			}
			$.ajax({
				type:"post",
				url:"{:U('Content/del_id')}",
				dataType: "json",
				data:{
					del_id:value,
				},
				success:
						function(data){
							alert(data);
						},

			});
			//ajax 进行删除 END
		};

		function fn(){
			if(confirm("确定删除吗")){
				getValue();
				location.reload();
				history.go(0);
			}else{
				history.go(0);
			}
		}


		function allchk(){
			var chknum = $("#list :checkbox").size();
			var chk = 0;
			$("#list :checkbox").each(function () {
				if($(this).prop("checked")==true){
					chk++;
				}
			});
			if(chknum==chk){
				$("#all").prop("checked",true);
			}else{
				$("#all").prop("checked",false);
			}
		}


		<!-- 排序开始-->
		$(":text").change(function(){
			$.ajax({
				type:"post",
				url:"{:U('Content/listorder')}",
				dataType: "json",
				data:{
					listorder:$(this).val(),
					listorder_id:$(this).data("orderid"),
				},
				success:
						function(data){
							alert(data);
						},

			});

		});
		<!-- 排序结束-->


	</script>

</section>
<!-- Main content END-->

{/block}